﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Windows;
using System.Windows.Documents.Serialization;

namespace Lds.Ward.PhotoDirectory.WpfApp {
	/// <summary>
	/// Interaction logic for App.xaml
	/// </summary>
	public partial class App : Application {
		/// <summary>Handler called when the application starts up.</sumary>
		void application_Startup(object sender, StartupEventArgs e) {
			try {
				SerializerProvider.RegisterSerializer(SerializerDescriptor.CreateFromFactoryInstance(new XamlSerializerFactory()), false);
			} catch (UnauthorizedAccessException ex) {
				MessageBox.Show("Failed to register XPS serializer.  Saving to an XPS file will be disabled.", 
					"Ward Photo Directory initialization error.", MessageBoxButton.OK, MessageBoxImage.Error);
			}
		}

		void application_Exit(object sender, ExitEventArgs e) {
			try {
				SerializerProvider.UnregisterSerializer(SerializerDescriptor.CreateFromFactoryInstance(new XamlSerializerFactory()));
			} catch (UnauthorizedAccessException) {
			}
		}
	}
}
